#include <stdio.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <unistd.h>
#include <stdlib.h>
#include <fcntl.h>
#include <mtd/mtd-user.h>
#include <sys/mount.h> 

int main(int argc, char *argv[])
{
    char *mtddevname = argv[1];
    printf("mtddevname = %s\n", mtddevname);
    int fd = open(mtddevname, O_RDONLY);
    if (fd < 0) return -1;

    struct mtd_info_user mtd_info;
    int ret = ioctl(fd, MEMGETINFO, &mtd_info);
    close(fd);
    printf("1\n");
    if (ret < 0) return -1;
    printf("mtd_info.size = %x", mtd_info.size);

    return 0;
}
 
